<?php

class webinterface {
	public $p_title    = "Chopito Admin: "; 
	public $p_script   = array();
	public $p_docready = array();
	public $p_content  = array();
	
	function set_title($title){
		$this->p_title = "Chopito Admin: " . $title;
	}

	function add_script($script){
		$this->p_script[] = $script;
	}


	function add_docready_script($script){
		$this->p_docready[] = $script;
	}

	function add_content($content){
		$this->p_content[] = $content;
	}

	function head(){
	echo <<< END
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>
END;
	print $this->p_title;
	echo <<< END
</title>
    <link type="text/css" href="css/menu.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/menu.js"></script>
    <style type="text/css" title="currentStyle">
	@import "css/demo_page.css";
	@import "css/demo_table.css";
    </style>
    <link type="text/css" href="css/custom-theme/jquery-ui-1.8.custom.css" rel="stylesheet" />	
    <script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></script>
    <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>

		<script type="text/javascript" charset="utf-8">
			$(document).ready(function(){
END;
		/* START DOCUMENT READY FUNCTIONS */
		for ($i = 0; $i < count($this->p_docready); $i++){
			print $this->p_docready[$i];
		}

		/* END DOCUMENT READY FUNCTIONS */

		echo <<< END
} );
		</script>

END;
	/* START SCRIPT CONTENTS HERE */
	for ($i = 0; $i < count($this->p_script); $i++){
		print $this->p_script[$i];
	}
	/* END SCRIPT CONTENTS HERE */

	print "</head>";
	}

	function body() {
	echo <<< END
<body>

<style type="text/css">
* { margin:0;
    padding:0;
}
html,body{
    margin:0px;
    height:100%;
}
div#page { 
    background:#A5A8AA;
    text-align:left;
    margin:0 auto;
    padding:20px 0 10px;
    position:relative;
    width:780px;
    border:1px solid #ddd;
    border-top:none;
    height: 100%;
}
body { background:#4A5155; }
div#menu { margin:5px auto; }
div#copyright {
    font:11px 'Trebuchet MS';
    color:#222;
    text-indent:30px;
    padding:40px 0 0 0;
}
div#copyright a { color:#aaa; }
div#copyright a:hover { color:#222; }
</style>

<div id="page">
<div id="menu">
    <ul class="menu">
        <li><a href="#" class="parent"><span>Status</span></a>
            <ul>
                <li><a href="#" class="parent"><span>Sub Item 1</span></a>
                    <ul>
                        <li><a href="#" class="parent"><span>Sub Item 1.1</span></a>
                            <ul>
                                <li><a href="#"><span>Sub Item 1.1.1</span></a></li>
                                <li><a href="#"><span>Sub Item 1.1.2</span></a></li>
                            </ul>
                        </li>
                        <li><a href="#"><span>Sub Item 1.2</span></a></li>
                        <li><a href="#"><span>Sub Item 1.3</span></a></li>
                        <li><a href="#"><span>Sub Item 1.4</span></a></li>
                        <li><a href="#"><span>Sub Item 1.5</span></a></li>
                        <li><a href="#"><span>Sub Item 1.6</span></a></li>
                        <li><a href="#" class="parent"><span>Sub Item 1.7</span></a>
                            <ul>
                                <li><a href="#"><span>Sub Item 1.7.1</span></a></li>
                                <li><a href="#"><span>Sub Item 1.7.2</span></a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li><a href="#"><span>Sub Item 2</span></a></li>
                <li><a href="#"><span>Sub Item 3</span></a></li>
            </ul>
        </li>
        <li><a href="#"><span>Configuration</span></a>
            <ul>
                <li><a href="#" class="parent"><span>Proxys</span></a>
		    <ul>
                        <li><a href="#"><span><a href="show_proxys.php">List</a></span></a></li>
                        <li><a href="#"><span><a href="show_proxys.php?active=1">Active</a></span></a></li>
                        <li><a href="#"><span><a href="add_proxys.php">Add</a></span></a></li>
		    </ul>
		</li>
                <li><a href="#" class="parent"><span>Groups</span></a>
                    <ul>
                        <li><a href="#"><span><a href="show_host_group.php">Hosts</a></span></a></li>
                        <li><a href="#"><span><a href="show_proxy_group.php">Proxys</a></span></a></li>
                    </ul>
                </li>
                <li><a href="#"><span><a href="show_rules.php">Rules</a></span></a></li>
            </ul>
        </li>
        <li><a href="#"><span>Statistics</span></a></li>
        <li><a href="#"><span>Help</span></a></li>
        <li class="last"><a href="#"><span>About</span></a></li>
    </ul>
</div>
<br><br>
END;
	/* CONTENTS HERE */
	for ($i = 0; $i < count($this->p_content); $i++){
		print $this->p_content[$i];
	}

	echo <<< END
</div>

<div style="display: none;"><!-- You can see this copyright notice in About menu -->
<div id="copyright">Copyright &copy; 2010 <a href="http://apycom.com/">Apycom jQuery Menus</a></div>
</div>

</body>
</html>
END;
	}

	function commit(){
		$this->head();
		$this->body();
	}
}

?>
